package com.harvey.guava.utilities;

import com.google.common.base.Stopwatch;

import java.time.Duration;
import java.util.concurrent.TimeUnit;

import static org.checkerframework.checker.units.qual.Prefix.nano;

/**
 * @author harvey
 * @Description
 * @date 2020-03-27 10:42
 * @since
 */

public class StopWatchExample {


    public static void main(String[] args) throws InterruptedException {

       // Elapsed 过去的. 可以计算一个任务执行的时间


        Stopwatch stopwatch = Stopwatch.createStarted();

        TimeUnit.SECONDS.sleep(2);

        System.out.println(stopwatch.stop());

        stopwatch.reset().start();
        TimeUnit.MILLISECONDS.sleep(100);
        System.out.println(stopwatch.stop());

    }

}
